#include <stdio.h>
#include <stdlib.h>
#include <malloc.h>
typedef struct node {
    int data;
    struct node *next;
}Node;

Node * CreatList()//创建表头
{
	Node *phead = (Node *)malloc(sizeof(Node));
	phead->next=NULL;
	return phead;
}
Node * CreatNode(Node * phead)//创建节点
{
	int n;
	scanf("%d",&n);
	while(n--){
	 Node * newPoint = (Node *)malloc(sizeof(Node));//创建一个新节点
			   if(newPoint == 0)
				  {
					  printf("内存分配错误\n");
					  break;
				  }
					 scanf("%d", &newPoint->data);
					 phead->next = newPoint;
					 phead = newPoint;
				}
	phead -> next = NULL;
	return 0;
}
void ShowList(struct node * headNode)//打印链表
{
   struct node * pMove = headNode->next;
   while(pMove)
   {
    printf("%d ",pMove->data);
	pMove=pMove->next;
   }

}
int Length(Node * phead)//统计节点个数
{
    int i=0;
    struct node * pMove = phead->next;
     while(pMove)
	   {
	    i++;
		pMove=pMove->next;
	   }
	 return i;//返回节点个数
}
int main(void)
{
    Node *phead;
    phead = CreatList();
    CreatNode(phead);
    ShowList(phead);
    printf("\n%d", Length(phead));
    return 0;
}